<template>
  <div class="company_mian">
    <div class="company_mian_item" v-for="(item, index) in companyList" :key="index">
      <div class="company_main_L">
        <!-- <div class="company_item_img">
          <img
            :src="`https://bootapi.51bmj.cn/sys/common/static/${item.logo}`"
            alt=""
          />
        </div>-->
        <div class="company_item_content">
          <div class="company_name">{{ item.companyName }}</div>
          <div class="company_data">认领时间: {{ item.createTime }}</div>
          <div
            class="company_data"
            v-if="item.claimStatus == 0"
            style="color: rgb(68, 162, 255)"
          >待审核</div>
          <div
            class="company_data"
            v-if="item.claimStatus == 1"
            style="color: rgb(68, 162, 255)"
          >认领失败</div>
          <div
            class="company_data"
            v-if="item.claimStatus == 2"
            style="color: rgb(68, 162, 255)"
          >认领成功</div>
        </div>
      </div>
      <div class="company_item_del changeHanld" @click="isDel(item.id)">删除</div>
    </div>
    <div class="noDataList_item">
      <div class="noDataList" v-if="companyList.length == 0">
        <img src="../../../../static/image/noData.png" alt />
        <div class="displayimg">
          您还没有认领的企业哦，
          <span class="gosearch changeHanld" @click="$router.push('/search')">快点我去认领吧</span>
        </div>
      </div>
    </div>

    <div class="pageList" v-show="companyList.length != 0">
      <paging ref="paging_zi" @CurrentPage="accept_CurrentValue" />
    </div>
  </div>
</template>

<script>
import paging from "../../../components/paging.vue";
import { postRequest, commonRequest } from "../../../api/api.js";
export default {
  components: {
    paging
  },
  data() {
    return {
      centerDialogVisible: false,
      companyList: []
    };
  },
  mounted() {
    this.getDataList(); // 获取列表数据
  },
  methods: {
    accept_CurrentValue: function(value) {
      console.log(value);
    },
    // 点击删除按钮
    isDel(id) {
      this.$confirm("", {
        cancelButtonText: "是的",
        confirmButtonText: "取消",
        center: true,
        showClose: false,
        closeOnClickModal: false,
        title: "确认删除已认领的企业吗?"
      })
        .then(() => {
          // 取消操作;
          this.$message({
            type: "success",
            message: "已取消删除!"
          });
        })
        .catch(() => {
          // 确认删除
          postRequest(
            `"/api/cms/cmsCompanyClaim/delCompanyClaim?id=${id}"`
          ).then(res => {
            this.$message({
              type: "info",
              message: res.result
            });
          });
        });
    },

    // 获取数据列表
    getDataList() {
      commonRequest("/api/cms/cmsCompanyClaim/list").then(res => {
        this.companyList = res.records;
        this.$refs.paging_zi.totalValue(res.total);
      });
    }
  }
};
</script>

<style lang="less" scoped>
.dialog-footer {
  display: flex;
  justify-content: space-around;
}
.dialog-footer button {
  width: 70px;
  height: 30px;
  border-radius: 6px;
  color: #fff;
  &:nth-child(1) {
    background: none;
    border: 1px solid #ccc;
    color: #000;
  }
}
.company_mian {
  padding-bottom: 20px;
  .noDataList_item {
    width: calc(1200px - 322px);
    height: 490px;
    display: flex;
    justify-content: center;
    align-items: center;
    .noDataList {
      display: flex;
      justify-content: center;
      flex-direction: column;
      align-items: center;
      font-size: 12px;
      color: #545454;
      span.gosearch {
        color: #44b3ff;
      }
      img {
        width: 150px;
        margin-bottom: 20px;
      }
    }
  }

  .company_mian_item {
    height: 100px;
    width: 900px;
    display: flex;
    padding: 0 10px;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    .company_main_L {
      display: flex;
      .company_item_img {
        img {
          width: 60px;
          height: 60px;
        }
      }
      .company_item_content {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-left: 20px;
        .company_name {
          font-size: 18px;
          color: #333;
          font-weight: 700;
        }
        .company_data {
          font-size: 14px;
          color: #999999;
          margin-left: 20px;
        }
      }
    }
    .company_item_del {
      display: flex;
      justify-content: center;
      align-items: center;
      color: #999999;
      width: 50px;
      height: 28px;
      background: #ffffff;
      border: 1px solid #daeaf5;
      border-radius: 4px;
    }
  }
  .pageList {
    height: 100px;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
  }
}
</style>
